package com.mall.controller;


import com.mall.entity.Area;
import com.mall.httpResult.HttpResult;
import com.mall.httpResult.ResultCodeEnum;
import com.mall.service.AreaService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 中国地区信息 前端控制器
 * </p>
 *
 * @author fire
 * @since 2020-04-16
 */
@RestController
@RequestMapping("/area")
public class AreaController {
    
    @Autowired
    private AreaService areaService;
    
    @ApiOperation("获取下一级的全部地址")
    @GetMapping("getChildAddress")
    public HttpResult getChildAddress(@RequestParam("superCode") String superCode) {

        List<Area> list = new ArrayList();
        try {
            list = areaService.getChildAddress(superCode);
        } catch (Exception e) {
            return HttpResult.failure(ResultCodeEnum.SERVER_ERROR, e.getMessage());
        }
        return HttpResult.success(list);
    }
}

